package cn.ultrarisk.scadmin.manager.biz.user.valid;

import cn.ultrarisk.scadmin.manager.biz.user.dao.AdminDAO;
import cn.ultrarisk.scadmin.manager.exception.BizCheckedException;
import cn.ultrarisk.scadmin.manager.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * AdminValidator
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/5/29
 * @since V1.0
 */
@Component
public class AdminValidator {
    @Autowired
    private AdminDAO adminDAO;

    public void validAccount(String account) {
        if (StringUtil.isEmpty(account)) {
            throw new BizCheckedException("the account can't be empty");
        }
        if (adminDAO.getByAccount(account) != null) {
            throw new BizCheckedException("the account is exist");
        }
    }
}

